package com.cskaoyan.controller.backStage;

import com.cskaoyan.model.Keyword;
import com.cskaoyan.model.bo.BaseParamBO;
import com.cskaoyan.model.vo.BaseRespVO;
import com.cskaoyan.model.vo.DataVO;
import com.cskaoyan.model.vo.ExceptionVO;
import com.cskaoyan.service.KeywordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: KeywordController
 * @Description: TODO  关键词管理模块
 * @Author:zhoukang
 * @Date: 2022/5/6 14:20
 * @Version: 1.0
 **/
@RestController
@RequestMapping("admin/keyword")
public class KeywordController {
    @Autowired
    KeywordService keyWordService;

    /**
     * @author: zhoukang
     * @description: TODO 查询keyword列表
     * @date: 2022/5/6 14:44
     */
    @RequiresPermissions("admin:issue:list")
    @RequestMapping("list")
    public BaseRespVO keywordList(BaseParamBO param, String keyword, String url){
        DataVO<Keyword> keywordDataVO = keyWordService.query(param,keyword,url);
        return BaseRespVO.ok(keywordDataVO);
    }

    /**
     * @author: zhoukang
     * @description: TODO 添加关键字
     * @date: 2022/5/6 15:24
     */
    @RequiresPermissions("admin:issue:create")
    @RequestMapping("create")
    public BaseRespVO keywordCreate(@RequestBody Keyword keyword){
        Keyword keywordRes = keyWordService.insert(keyword);
        return BaseRespVO.ok(keywordRes);
    }

    /**
     * @author: zhoukang
     * @description: TODO 逻辑删除关键字
     * @date: 2022/5/6 17:35
     */
    @RequiresPermissions("admin:issue:delete")
    @RequestMapping("delete")
    public ExceptionVO keywordDelete(@RequestBody Keyword keyword){
        keyWordService.delete(keyword);
        return new ExceptionVO();
    }

    /**
     * @author: zhoukang
     * @description: TODO 修改关键字信息
     * @date: 2022/5/6 17:41
     */
    @RequiresPermissions("admin:issue:update")
    @RequestMapping("update")
    public BaseRespVO keywordUpdate(@RequestBody Keyword keyword){
        Keyword keywordData = keyWordService.update(keyword);
        return BaseRespVO.ok(keywordData);
    }
}
